using System.IO;
using UnityEngine;

/*
* Introduction：
* Creator：
*/

/// <summary>
/// 
/// </summary>
public class CommonPath
{

    /// <summary>
    /// StreamingAsset 文件夹资源根目录 在各平台的路径
    /// </summary>
    /// <returns></returns>
    private static string m_StreamingAsset = "";
    public static string streamingAsset
    {
        get
        {
            if (string.IsNullOrEmpty(m_StreamingAsset))
            {
#if UNITY_EDITOR || UNITY_STANDALONE
                m_StreamingAsset = "file://" + Application.dataPath + "/StreamingAssets/";
#elif UNITY_ANDROID
				m_StreamingAsset = "jar:file://" + Application.dataPath + "/!/assets/";
#elif UNITY_IPHONE
				m_StreamingAsset = "file://" + Application.dataPath + "/Raw/";
#endif
            }
            return m_StreamingAsset;
        }
    }


    /// <summary>
    /// persistentDataPath 持久文件在各平台的路径 没有“File://”
    /// </summary>
    private static string m_persistentDataPath = "";
    public static string persistentDataPath
    {
        get
        {
            if (string.IsNullOrEmpty(m_persistentDataPath))
            {
#if UNITY_EDITOR || UNITY_STANDALONE
                m_persistentDataPath = Application.dataPath + "/../persistentDataPath";
                if (!Directory.Exists(m_persistentDataPath))
                    Directory.CreateDirectory(m_persistentDataPath);
#else
				m_persistentDataPath = Application.persistentDataPath;
#endif
                m_persistentDataPath = m_persistentDataPath + "/";
            }
            return m_persistentDataPath;
        }
    }





    public static string OS
    {
        get
        {
            switch (Application.platform)
            {
                case RuntimePlatform.Android:
                    return "Android";
                case RuntimePlatform.IPhonePlayer:
                    return "iOS";
                default:
                    return "Windows";
            }
        }
    }

    public static string persistentDataPathAndPlatform
    {
        get
        {
            return persistentDataPath + OS;
        }
    }

}
